package com.itaming.lycheeframework.core.properties;

import com.itaming.lycheeframework.common.constant.FrameworkConstant;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * Executor配置参数
 *
 * @author A.Ming
 */
@ConfigurationProperties(LycheeExecutorProperties.PREFIX)
@Data
public class LycheeExecutorProperties {

    /**
     * 配置前缀
     */
    public static final String PREFIX = FrameworkConstant.PROPERTIES_ROOT_NAME + ".executor";

    /**
     * 异步任务配置
     */
    private AsyncProperties async = new AsyncProperties();

    /**
     * 定时任务配置
     */
    private SchedulingProperties scheduling = new SchedulingProperties();

    /**
     * 异步任务配置
     */
    @Data
    public static class AsyncProperties {

        /**
         * 线程池名称前缀
         */
        private String threadNamePrefix = "async-exec-";

        /**
         * 核心线程数
         */
        private int corePoolSize = 10;

        /**
         * 最大线程数
         */
        private int maxPoolSize = 50;

        /**
         * 队列容量
         */
        private int queueCapacity = 100;

        /**
         * 线程存活时间(秒)
         */
        private int keepAliveSeconds = 60;

    }

    /**
     * 定时任务配置
     */
    @Data
    public static class SchedulingProperties {

        /**
         * 线程池名称前缀
         */
        private String threadNamePrefix = "sched-exec-";

        /**
         * 线程数
         */
        private int poolSize = 10;

    }

}
